<template>
  <div id="echarts1"></div>
</template>

<script>
import * as echarts from "echarts";

export default {
  name: "Echarts1",
  props:{
    date:{
      require:true,
    }
  },
  data() {
    return {
      echarts: null
    }
  },
  mounted() {
    this.initEcharts()
  },
  methods: {
    initEcharts() {
      const chartDom = document.getElementById('echarts1')
      this.echarts = echarts.init(chartDom)
    },
    setEChartsOptions(data){
      const newData = data.map((item)=>({
        value:item.count,
        name:item.status
      }))
      const option = {
        title: {
          text: `${this.date}年项目状态:`,
          // subtext: 'Fake Data',
          left: 'left'
        },
        tooltip: {
          trigger: 'item'
        },
        legend: {
          orient: 'vertical',
          left: 'right',
        },
        series: [
          {
            name: '项目状态：',
            type: 'pie',
            radius: '50%',
            data: newData,
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      };
      this.echarts&&this.echarts.setOption(option);
    }
  }
}
</script>

<style scoped lang="scss">
#echarts1{
  width: 100%;
  height: 100%;
}
</style>
